cmake_minimum_required(VERSION 3.8)
project(image_service)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(example_interfaces REQUIRED)
find_package(rosidl_default_generators REQUIRED)
find_package(OpenCV REQUIRED)
# 输出OpenCV信息
message(STATUS "include path: ${OpenCV_INCLUDE_DIRS}")

rosidl_generate_interfaces(${PROJECT_NAME}
  "srv/PrintImagePath.srv"
)

set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

# 链接retinaface库
set(RETINAFACE_LIB_PATH "/mnt/sdcard/retinaface_lib/build/libretinaface_lib.so")
set(RETINAFACE_INCLUDE_PATH "/mnt/sdcard/retinaface_lib/include")

# 链接facenet库
set(FACENET_LIB_PATH "/mnt/sdcard/facenet_lib/build/libfacenet_lib.so")
set(FACENET_INCLUDE_PATH "/mnt/sdcard/facenet_lib/include")


add_executable(image_service_node src/image_service_node.cpp)
ament_target_dependencies(image_service_node rclcpp example_interfaces)
target_link_libraries(image_service_node
  ${rclcpp_LIBRARIES}
  ${OpenCV_LIBS}
  ${RETINAFACE_LIB_PATH}
  ${FACENET_LIB_PATH}
  "${PROJECT_NAME}__rosidl_typesupport_cpp"
)
target_include_directories(image_service_node PRIVATE
  ${OpenCV_INCLUDE_DIRS}
  ${RETINAFACE_INCLUDE_PATH}
  ${FACENET_INCLUDE_PATH}
)

install(TARGETS
  image_service_node
  DESTINATION lib/${PROJECT_NAME})

ament_package()
